-- @owner: opentestcase023
-- @date: 2022/02/24
-- @testpoint: 设置触发条件与实际触发条件不符，不触发更新des表

--step1:建表;expect:成功
drop table if exists t_trigger_src cascade;
drop table if exists t_trigger_des cascade;
create table t_trigger_src(id1 int, id2 int, id3 int) with (storage_type=ustore);
create table t_trigger_des(id1 int, id2 int, id3 int) with (storage_type=ustore);

--step2:在更新src表id1=2前，触发更新des表更新操作;expect:未触发更新触发器
create or replace function tri_update_func() returns trigger as
$$
  declare
  begin
  update t_trigger_des set id3 = new.id3 where id1=old.id1;
  return new;
  end
$$ language plpgsql;
/
create trigger update_trigger before update on t_trigger_src
   for each row
   when(new.id1=2)
   execute procedure tri_update_func();
/
insert into t_trigger_src values(1,1,1),(2,2,2);
insert into t_trigger_des values(1,1,1),(2,2,2);
select * from t_trigger_des order by id1;
update t_trigger_src set id3=10 where id1=1;
select * from t_trigger_des order by id1;

--step3:清理环境;expect:成功
drop table if exists t_trigger_src cascade;
drop table if exists t_trigger_des cascade;